const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
    mode: 'none',
    entry: {
        index: './src/main.js',
        other: './src/other.js'
    },
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './src/views/index.html',
            filename: 'index.html',
            chunks: [
                'index',
            'other',
             'vendors',
             'commons']
        }),
        new CleanWebpackPlugin()
    ],
    module: {
        rules:[
            {
                test: /\.md$/,
                use: [
                    'html-loader',
                    './markdown-loader.js'
                ]
            }
        ]
    },
    optimization: {
        splitChunks: {
            chunks: 'all',
            cacheGroups: {
                vendors: {
                    name: 'vendors',
                    minSize: 0,
                    minChunks: 1,
                    test: /[\\/]node_modules[\\/]/,
                    priority: 2
                },
                commons: {
                    name: 'commons',
                    minSize: 0,
                    minChunks: 2,
                    priority: 1
                }
            }
            
        }
    }
}